package com.edu.tankgame;

import javax.swing.*;
import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.Scanner;

public class TankStart extends JFrame {
    //定义一个Mypanel
    MyPanel mp = null;
    static Scanner scanner = new Scanner(System.in);
    public static void main(String[] args) {


        TankStart tankStart = new TankStart();
    }
    public TankStart() {
        //将定义好的panel对象创建
        System.out.println("请输入选择：\t\n 1.新游戏\t\n 2.继续游戏");
        String key = scanner.next();
        mp = new MyPanel(key);
        new Thread(mp).start();
        this.add(mp);//将绘图区域添加
        //画板设置
        this.setSize(1300, 950);
        this.setBackground(Color.black);
        this.addKeyListener(mp);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setVisible(true);

        //增加响应JFrame窗口的处理
        this.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e) {
                Recorder.keepRecord();
                System.exit(0);
            }
        });
    }
}
